<?php
//异常错误显示
const SHOW_MESSAGE = 500;

const DEFAULT_CODE = 500;
//异常错误转化显示
const COMMON_MESSAGE = 1999;

const LOG_NO_QUERY_STRING = -1000;

const R_REDIS_ERROR = 'error'; //redis异常返回值

const M_START = 0;
const M_END = 10000;


#redis key (以R开头)
const R_LOGIN_TOKEN = 'login:token:'; //登陆token
const R_LOGIN_TOKEN_INFO = 'login:token:info'; //登陆token信息
const R_LOGIN_TOKEN_HASH = 'login:token:hash'; //登陆token
const R_LOGIN_TOKEN_HASH_MULTI = 'login:token:hash:multi'; //登陆token
const R_USER_INFO = 'user:info'; //用户信息保存名称头像等
const R_IP = 'geoip:info';


//金额类型
const BALANCE_USABLE = 1; //可用余额
const BALANCE_PREPAY = 2; //预付金额

function tt_balance_type($type, $all = false)
{
    $arr = [
        BALANCE_USABLE => '余额',
        BALANCE_PREPAY => '预付金额',
    ];
    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}


//状态
const STATUS_NO = 0;
const STATUS_YES = 1;

function tt_status_yes_no($type, $all = false)
{
    $arr = [
        STATUS_NO => '否',
        STATUS_YES => '是',
    ];
    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}

//状态
const STATUS_DISABLED = 0;
const STATUS_ENABLED = 1;

function tt_status($type, $all = false)
{
    $arr = [
        STATUS_DISABLED => '禁用',
        STATUS_ENABLED => '启用',
    ];
    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}
const ASSET_SYMBOL_DEFAULT = "USDT";

const ASSET_DEPOSITS = 1;   //充值
const ASSET_DEPOSITS_SYS = 91;   //系统调账
const ASSET_WITHDRAW = 2;   //提现
const ASSET_WITHDRAW_BACK = 29;
const ASSET_WITHDRAW_SYS = 92;   //系统调账
const ASSET_FREEZE_RELEASE = 30;

const ASSET_MANUAL_SETTLE = 40;


function tt_asset($type, $all = false)
{
    $arr = [
        ASSET_DEPOSITS => "充值",
        ASSET_DEPOSITS_SYS => "调账充值",
        ASSET_WITHDRAW => "提现",
        ASSET_WITHDRAW_SYS => "调账提现",
        ASSET_WITHDRAW_BACK => "提现退回",
        ASSET_MANUAL_SETTLE => "手动结算"
    ];

    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}

const DEPOSIT_COMMIT = 1;
const DEPOSIT_SUCCESS = 2;
const DEPOSIT_FAIL = 3;

/**
 * 充值
 * @param $type
 * @param $all
 * @return string|string[]
 */
function tt_deposit($type, $all = false)
{
    $arr = [
        DEPOSIT_COMMIT => "已提交",
        DEPOSIT_SUCCESS => "成功",
        DEPOSIT_FAIL => "失败",
    ];
    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}


const DEPOSIT_METHOD_CHAIN = 1;
const DEPOSIT_METHOD_BANK = 2;

/**
 * 充值方式
 * @param $type
 * @param $all
 * @return string|string[]
 */
function tt_deposit_method($type, $all = false)
{
    $arr = [
        DEPOSIT_METHOD_CHAIN => "链",
        DEPOSIT_METHOD_BANK => "银行卡",
    ];
    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}


const WITHDRAW_COMMIT = 1;
const WITHDRAW_SUCCESS = 2;
const WITHDRAW_FAIL = 3;

/**
 * @param $type
 * @param $all
 * @return string|string[]
 */
function tt_withdraw($type, $all = false)
{
    $arr = [
        WITHDRAW_COMMIT => "已提交",
        WITHDRAW_SUCCESS => "成功",
        WITHDRAW_FAIL => "失败",
    ];
    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}

const USER_AUTH_CHECK = 1; //待审核
const USER_AUTH_SUCCESS = 2; //已通过
const USER_AUTH_FAIL = 3; //已驳回

function tt_user_auth($type, $all = false)
{
    $arr = [
        USER_AUTH_CHECK => "待审核",
        USER_AUTH_SUCCESS => "已通过",
        USER_AUTH_FAIL => "已驳回",
    ];
    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}

const USER_SIGN_STATUS = 0;//未提交
const USER_SIGN_STATUS_COMMIT = 1;//已提交
const USER_SIGN_STATUS_SUCCESS = 2;//已通过

function tt_user_sign_status($type, $all = false)
{
    $arr = [
        USER_SIGN_STATUS => "未提交",
        USER_SIGN_STATUS_COMMIT => "已提交",
        USER_SIGN_STATUS_SUCCESS => "已通过",
    ];
    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}

const USER_NOTIFICATION_DEPOSIT_SUCCESS = 1;
const USER_NOTIFICATION_DEPOSIT_FAIL = 2;
const USER_NOTIFICATION_WITHDRAW_SUCCESS = 3;
const USER_NOTIFICATION_WITHDRAW_FAIL = 4;

function tt_user_notification_type($type, $all = false)
{
    $arr = [
        USER_NOTIFICATION_DEPOSIT_SUCCESS => "充值成功",
        USER_NOTIFICATION_DEPOSIT_FAIL => "充值失败",
        USER_NOTIFICATION_WITHDRAW_SUCCESS => "提现成功",
        USER_NOTIFICATION_WITHDRAW_FAIL => "提现失败",
    ];
    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}


const RISK_STATUS_WIN = 1;//赢
const RISK_STATUS_LOSS = 2;//输
const RISK_STATUS_NONE = 3;//无

function tt_risk_status($type, $all = false)
{
    $arr = [
        RISK_STATUS_WIN => "赢",
        RISK_STATUS_LOSS => "输",
        RISK_STATUS_NONE => "无",
    ];
    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}

function tt_lang($type, $all = false)
{
    $arr = [
        'en' => '英文',
        'zh_CN' => '中文',
//        'zh_TW' => '中文(繁体)',
//        'ar' => '阿拉伯',
//        'bd' => '孟加拉',
//        'de' => '德语',
//        'es' => '西班牙语',
//        'fr' => '法语',
//        'id' => '印尼语',
//        'in' => '印度语',
//        'ja' => '日语',
        'ko' => '韩语',
//        'ms' => '马来语',
//        'pt' => '葡萄牙语',
//        'ru' => '俄罗斯语',
//        'th' => '泰语',
//        'vi' => '越南语',
    ];
    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}


const TAKEOUT_STATUS_COMMIT = 0;
const TAKEOUT_STATUS_DELIVER = 1;
const TAKEOUT_STATUS_CANCEL = 2;
const TAKEOUT_STATUS_SUCCESS = 3;

function tt_takeout_status($type, $all = false)
{
    $arr = [
        TAKEOUT_STATUS_COMMIT => '提交',
        TAKEOUT_STATUS_DELIVER => '派送中',
        TAKEOUT_STATUS_CANCEL => '取消',
        TAKEOUT_STATUS_SUCCESS => '成功',
    ];
    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}

const WITHDRAW_STATUS_COMMIT = 0;
const WITHDRAW_STATUS_DELIVER = 1;
const WITHDRAW_STATUS_SUCCESS = 2;
const WITHDRAW_STATUS_FAIL = 3;

function tt_withdraw_status($type, $all = false)
{
    $arr = [
        WITHDRAW_STATUS_COMMIT => '未发放',
        WITHDRAW_STATUS_DELIVER => '转账中',
        WITHDRAW_STATUS_SUCCESS => '成功',
        WITHDRAW_STATUS_FAIL => '失败',
    ];
    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}


const TX_STATUS_UNTREATED = 0; //未处理
const TX_STATUS_PROCESSING = 1;//处理中

const TX_STATUS_SUCCESS = 2;//成功

const TX_STATUS_FAIL = 3; //失败

const TX_STATUS_SEND = 4;


function tt_tx_status($type, $all = false)
{
    $arr = [
        TX_STATUS_UNTREATED => '未处理',
        TX_STATUS_PROCESSING => '处理中',
        TX_STATUS_SEND => '发送',
        TX_STATUS_FAIL => '失败',
        TX_STATUS_SUCCESS => '成功',

    ];
    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}


const TRADE_STATUS_UNTREATED = 0;
const TRADE_STATUS_PROCESSING = 1;
const TRADE_STATUS_SUCCESS = 2;
const TRADE_STATUS_FAIL = 3;

const TRADE_STATUS_SEND = 4;

function tt_trade_status($type, $all = false)
{
    $arr = [
        TRADE_STATUS_UNTREATED => '提交',
        TRADE_STATUS_PROCESSING => '处理中',
//        TRADE_STATUS_SEND => '已发送',
        TRADE_STATUS_SUCCESS => '成功',
        TRADE_STATUS_FAIL => '失败',
    ];
    if ($all) {
        return $arr;
    } else {
        return $arr[$type] ?? "";
    }
}
